<template>
  <div class="Login">
    <div class="head">
      <h1 class="titleFontH1">物业管理</h1>
    </div>
    <div class="contain">
      <van-form style="margin-top:100px">
        <van-field
          v-model="username"
          name="用户名"
          label="用户名"
          style="margin: 16px;margin-bottom:45px;width:auto;background-color: none;"
          placeholder="请输入昵称或手机号"
        />
        <van-field
          v-model="password"
          type="password"
          name="密码"
          label="密码"
          style="margin: 16px;margin-bottom:45px;width:auto"
          placeholder="6-16位数字字母，区分大小写"
        />
        <div style="margin: 40px;">
          <van-button round block type="info" native-type="submit" @click="login">
            登录
          </van-button>
        </div>
        <div style="margin: 40px;height:50px;display:flex;justify-content:center;align-items:center">
          <van-button round block type="info" native-type="submit" to='/Register'>
            注册
          </van-button>
        </div>
      </van-form>
      <van-divider>第三方登录</van-divider>
      <div class="weixinqq">
        <van-row type="flex" justify="center">
          <van-col span="6">
            <svg class="icon" aria-hidden="true">
              <use xlink:href="#iconfont-weixin"></use>
            </svg>
          </van-col>
          <van-col offset="2" span="6">
            <svg class="icon" aria-hidden="true">
              <use xlink:href="#iconfont-QQ1"></use>
            </svg>
          </van-col>
        </van-row>
      </div>
    </div>
    <div class="btm">
      <van-row type="flex" justify="space-between" style="align-items:flex-start">
        <van-col span="6"><h3 @click="forget" class="fonts">忘记密码</h3></van-col>
        <van-col span="6"><h3 @click="look" class="fonts">随便看看</h3></van-col>
      </van-row>
    </div>
  </div>
</template>

<script>
import Vue from 'vue'
import { getLogin } from '../../rapper/Login/login'
import { Form, field, button, Field, Divider, Image as VanImage, Col, Row, Toast, Dialog } from 'vant'
Vue.use(Form).use(button).use(field).use(Field).use(Divider).use(VanImage).use(Col).use(Row).use(Toast)
export default {
  name: 'Login',

  data () {
    return {
      username: '',
      password: ''
    }
  },
  created () {
    this.getLogin()
  },
  methods: {
    async getLogin () {
      const res = await getLogin()
      console.log(res)
    },
    login () {
      if (this.username === 'admin' && this.password === 'admin') {
        this.$router.push('/Home')
      } else if (this.username.length === 0 || this.password.length === 0) {
        Dialog({ message: '请输入用户名和密码' })
      } else {
        Dialog({ message: '请输入正确的账号密码' })
      }
    },
    forget () {
      this.$router.push('/Forget')
    },
    look () {
      this.$router.push('/Home')
    }
  }
}
</script>

<style scoped>
.Login {
  width: 100%;
  height: 100%;
}
.titleFontH1{
  font-size: 20px;
  height: 100px;
  display:flex;
  justify-content:center;
  align-items:center;
}
.btm{
  margin: 20%  0 0 0 ;
}
.icon {
  width: 4em;
  height: 4em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
.fonts{
  font-size: 18px;
  /* color: #fff; */
}
</style>
